# -*- coding:utf-8 -*-
# author:zhou date:2019/5/10
# import sys
# import os
# import django
# sys.path.append("..")
# sys.path.append("../utils")
# os.environ.update({"DJANGO_SETTINGS_MODULE": "server.settings"})
# django.setup()
# from django.test import Client

# client = Client()

import requests
import pdb

baseUrl = u"http://127.0.0.1:8000/api/branch/"
testUrl = u"https://violin.kyshh.com/api/branch/"

def test():
    data = {

    }
    res = requests.get(testUrl + 'test/', data=data)
    # pdb.set_trace()
    print(res.content.decode('utf-8'))

# 新建活动
def newDaily():
    data = {
        'token': '357399f307fae56866aa',  
        'dailyType':'其他',
        'dailyTime': '10:00',  
        'dailyDate' : '2019-08-01',  
        'position' : '地点', 
        'topic': '主题',
        'attention': '注意事项',
        'participant': '积极分子', 
    }
    res = requests.post(baseUrl + 'newDaily/', data=data)
    print(res.content.decode('utf-8'))

# 获取活动列表
def getDailyList():
    data = {
        'token': '357399f307fae56866aa',  
    }
    res = requests.post(baseUrl + 'getDailyList/', data=data)
    print(res.content.decode('utf-8'))

def deleteDaily():
    data = {
        'token': '357399f307fae56866aa',  
        'dailyId':'5',
    }
    res = requests.post(baseUrl + 'deleteDaily/', data=data)
    print(res.content.decode('utf-8'))

def getContect():
    data = {
        'token': '357399f307fae56866aa',  
    }
    res = requests.post(baseUrl + 'getContect/', data=data)
    print(res.content.decode('utf-8'))

def saveArticle():
    data = {
        'articleTopic':'守初心',
        'title':'学党史·守初心 | 05全民族抗日战争的中流砥柱',
        'imgsrc':'https://mmbiz.qpic.cn/mmbiz_jpg/D9hVia1ibY8p3Ezuy7SibEeFzgFp3RshicGjoj593v5uPccXv0TpTRAvs5stKHOq7ibEnQTAyBcyQf98cF1JnyHZccQ/640?wx_fmt=jpeg&wxfrom=5&wx_lazy=1&wx_co=1',
        'txtsrc':'https://mp.weixin.qq.com/s/Zt_X1DHCritbJ6P3hvE5zQ',
        'preview':'1931年9月18日深夜，根据不平等条约驻扎在中国东北的日本关东军，向中国军队驻地北大营和沈阳 城发动进攻，这就是九一八事变。',

    }
    res = requests.post(baseUrl + 'saveArticle/', data=data)
    print(res.content.decode('utf-8'))



def getArticle():
    data = {
        'articleType': '党日活动',  
    }
    res = requests.post(baseUrl + 'getArticle/', data=data)
    print(res.content.decode('utf-8'))


def submitThink():
    data = {
        'token': 'f1f08e9153d345a15afb',  
        'content': '读书交流会感想',
        'dailyId':'4',
    }
    res = requests.post(baseUrl + 'submitThink/', data=data)
    print(res.content.decode('utf-8'))

def getSingleThink():
    data = {
        'token': 'f1f08e9153d345a15afb',  
        'dailyId':'4',
    }
    res = requests.post(baseUrl + 'getSingleThink/', data=data)
    print(res.content.decode('utf-8'))

def checkNotSubmit():
    data = {
        'dailyId':'4',
        "branch":'通三党支部'
    }
    res = requests.post(baseUrl + 'checkNotSubmit/', data=data)
    print(res.content.decode('utf-8'))

def getThinks():
    data = {
        'dailyId':'4',
        "branch":'通三党支部'
    }
    res = requests.post(baseUrl + 'getThinks/', data=data)
    print(res.content.decode('utf-8'))

def saveTest():
    data = {
        'question':'什么是党的“三大法宝',
        'answer':"统一战线、武装斗争、党的建设",
    }
    res = requests.post(baseUrl + 'saveTest/', data=data)
    print(res.content.decode('utf-8'))

def getTest():
    data = {
        'token':'734bf862d2085675cd85',  
    }
    res = requests.post(baseUrl + 'getTest/', data=data)
    print(res.content.decode('utf-8'))

if __name__ == '__main__':
    # test()
    # newDaily()
    # getDailyList()
    # deleteDaily()
    # getContect()
    saveArticle()
    # getArticle()
    # submitThink()
    # getSingleThink()
    # checkNotSubmit()
    # getThinks()
    # saveTest()
    # getTest()


